package ar.com.spsolutions.splilabrary.view.pages.home;

import java.util.List;

import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;

import ar.com.spsolutions.splibrary.book.Book;
import ar.com.spsolutions.splibrary.services.BookService;
import ar.com.spsolutions.splilabrary.view.version2.components.MainContainer;

public class PageContainer extends MainContainer {

    private static final long serialVersionUID = -6828608423958370491L;

    @Override
    protected void addComponents() {

        final BookService bookService = getEntityService().getBookService();

        final Form<Book> form = new Form<Book>("rankingForm");
        final List<Book> topFive = bookService.findTopFive();

        form.add(new ListView<Book>("bookRow", topFive) {

            private static final long serialVersionUID = -225635288982403804L;

            @Override
            protected void populateItem(final ListItem<Book> item) {
                item.add(new RankingBookPanel("book", item.getModelObject()));

            }
        });
        this.add(form);

    }
}
